local skel = fk.CreateSkill {
  name = "emo__qihen",
}

skel:addEffect(fk.RoundStart, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local tos = room:askToChoosePlayers(player, {
      min_num = 1, max_num = 99, skill_name = skel.name, targets = room:getOtherPlayers(player, false),
      prompt = "#emo__qihen-choose", no_indicate = true,
    })
    if #tos > 0 then
      event:setCostData(self, table.map(tos, Util.IdMapper))
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    player.room:setPlayerMark(player, skel.name, event:getCostData(self))
  end,
})

skel:addEffect(fk.HpChanged, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if target == player and data.num < 0 then
      local current = player.room.current
      return current and not current.dead and table.contains(player:getTableMark(skel.name), current.id)
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    player.room:addPlayerMark(player.room.current, "@emo__qihen-turn")
  end,
})

skel:addEffect(fk.TurnEnd, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return target == player and player:getMark("@emo__qihen-turn") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    player.room:loseHp(player, player:getMark("@emo__qihen-turn"), skel.name)
  end,
})


Fk:loadTranslationTable{
  ["emo__qihen"] = "欺恨",
  [":emo__qihen"] = "每轮开始时，你可以选择任意名其他角色，本轮当你于选择角色的回合内扣减体力值时，令其于回合结束时失去等量体力。",
  ["#emo__qihen-choose"] = "欺恨：选择任意名角色，若你于其回合内扣减体力，会令其失去等量体力",
  ["@emo__qihen-turn"] = "欺恨",
}

return skel
